/*
 * @Author: 
 * @Date: 2025-01-22 16:18:54
 * @LastEditor: zhuxiaoyi
 * @LastEditTime: 2025-01-23 15:23:41
 * @Description: 
 */
import { defineStore } from 'pinia';

export const useSubsystemStore = defineStore('subsystem', {
  state: () => ({
    selectedSubsystem: "4dec5e9f-d4d4-4bba-a807-e052514ee57e", // Default subsystem ID
    selectedRoleId: "", // Default subsystem ID
    user:{
      username:''
    }
  }),
  actions: {
    setSubsystem(id: string) {
      this.selectedSubsystem = id;
    },
    setRole(id: string) {
      this.selectedRoleId = id;
    },
    setUser(user:any){
      this.user = user
    }
  },
  getters: {
    getSubsystem: (state) => state.selectedSubsystem,
    getRole: (state) => state.selectedRoleId,
    getUser: (state) => state.user,
  },
  persist: {
    enabled: true,
    strategies: [
      {
        key: "subsystem", //设置存储的key  全部储存
        storage: localStorage,
        // paths: ["isCollapse"], //指定要长久化的字段  选择储存
      },
    ],
  },
});


